<html>
    <head>
        <script src="../../../../../../lib/externals/ext/adapter/ext/ext-base.js"></script>
        <script src="../../../../../../lib/externals/ext/ext-all-debug.js"></script>
        <script src="../../../../../lib/Ext.ux.js"></script>
    
        <script>
        
        function test_constructor(t) {
            
            t.plan(2);
            
            var store = new Ext.data.Store();
            var record_factory = Ext.data.Record.create(['text']);
            var record = new record_factory({text: 'foo'});
            store.add(record);
            
            var node = new Ext.ux.tree.TreeRecordNode({
                record: record,
                store: store
            });
            
            t.ok(node.store === store, "store well set");
            t.ok(node.record === record, "record well set");
            
            node.destroy();
            
        }
        
        function test_render(t) {

            t.plan(4);

            var store = new Ext.data.Store();
            var record_factory = Ext.data.Record.create(['text', 'displayInTree']);
            var record = new record_factory(
                {
                    text: 'foo',
                    displayInTree: true
                });
            store.add(record);
            
            var node = new Ext.ux.tree.TreeRecordNode({
                record: record,
                store: store,
                childNodeType: {
                    add: function() {
                        t.ok(true, "add function of childNodeType called");
                    }
                }
            });
            
            var panel = new Ext.tree.TreePanel({
                renderTo: "tree",
                root: node
            });

            t.eq(node.text, "foo", "check node.text copied from record");
            t.eq(node.hidden, false, "check node is not hidden");
            store.remove(record);
            t.eq(node.hidden, true, "check node is hidden");
            
        }
        
        </script>
    </head>
    <body>
        <div id="tree" style="width: 100px; height: 100px;"></div>
    </body>
</html>
